package dao;

import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class BatisUtil {
	private static SqlSessionFactory factory=null;
	static{
		try (InputStream iStream=Resources.getResourceAsStream("mybatis-config.xml")){
			factory=new SqlSessionFactoryBuilder().build(iStream);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public SqlSession getSession(boolean autoCommit){
		return factory.openSession(autoCommit);
	}
}
